package org.jivesoftware.smack.util;

import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.PrintStream;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.jivesoftware.smack.Connection;
import org.jivesoftware.smack.packet.Authentication;
import org.jivesoftware.smack.packet.Bind;
import org.jivesoftware.smack.packet.DefaultPacketExtension;
import org.jivesoftware.smack.packet.IQ;
import org.jivesoftware.smack.packet.IQ.Type;
import org.jivesoftware.smack.packet.Message;
import org.jivesoftware.smack.packet.Message.Type;
import org.jivesoftware.smack.packet.Packet;
import org.jivesoftware.smack.packet.PacketExtension;
import org.jivesoftware.smack.packet.Presence;
import org.jivesoftware.smack.packet.Presence.Mode;
import org.jivesoftware.smack.packet.Presence.Type;
import org.jivesoftware.smack.packet.Registration;
import org.jivesoftware.smack.packet.RosterPacket;
import org.jivesoftware.smack.packet.RosterPacket.Item;
import org.jivesoftware.smack.packet.RosterPacket.ItemStatus;
import org.jivesoftware.smack.packet.RosterPacket.ItemType;
import org.jivesoftware.smack.packet.StreamError;
import org.jivesoftware.smack.packet.XMPPError;
import org.jivesoftware.smack.packet.XMPPError.Condition;
import org.jivesoftware.smack.packet.XMPPError.Type;
import org.jivesoftware.smack.provider.IQProvider;
import org.jivesoftware.smack.provider.PacketExtensionProvider;
import org.jivesoftware.smack.provider.ProviderManager;
import org.jivesoftware.smack.sasl.SASLMechanism.Failure;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;

public class PacketParserUtils
{
  private static final String PROPERTIES_NAMESPACE = "http://www.jivesoftware.com/xmlns/xmpp/properties";

  public static Packet parseMessage(XmlPullParser paramXmlPullParser)
    throws Exception
  {
    Message localMessage = new Message();
    String str1 = paramXmlPullParser.getAttributeValue("", "id");
    localMessage.setPacketID(str1 == null ? "ID_NOT_AVAILABLE" : str1);
    localMessage.setTo(paramXmlPullParser.getAttributeValue("", "to"));
    localMessage.setFrom(paramXmlPullParser.getAttributeValue("", "from"));
    localMessage.setType(Message.Type.fromString(paramXmlPullParser.getAttributeValue("", "type")));
    String str2 = getLanguageAttribute(paramXmlPullParser);
    String str3 = null;
    if ((str2 != null) && (!"".equals(str2.trim())))
    {
      localMessage.setLanguage(str2);
      str3 = str2;
    }
    else
    {
      str3 = Packet.getDefaultLanguage();
    }
    int i = 0;
    String str4 = null;
    Map localMap = null;
    Object localObject;
    while (i == 0)
    {
      int j = paramXmlPullParser.next();
      if (j == 2)
      {
        localObject = paramXmlPullParser.getName();
        String str6 = paramXmlPullParser.getNamespace();
        String str7;
        String str8;
        if (((String)localObject).equals("subject"))
        {
          str7 = getLanguageAttribute(paramXmlPullParser);
          if (str7 == null)
            str7 = str3;
          str8 = parseContent(paramXmlPullParser);
          if (localMessage.getSubject(str7) == null)
            localMessage.addSubject(str7, str8);
        }
        else if (((String)localObject).equals("body"))
        {
          str7 = getLanguageAttribute(paramXmlPullParser);
          if (str7 == null)
            str7 = str3;
          str8 = parseContent(paramXmlPullParser);
          if (localMessage.getBody(str7) == null)
            localMessage.addBody(str7, str8);
        }
        else if (((String)localObject).equals("thread"))
        {
          if (str4 == null)
            str4 = paramXmlPullParser.nextText();
        }
        else if (((String)localObject).equals("error"))
        {
          localMessage.setError(parseError(paramXmlPullParser));
        }
        else if ((((String)localObject).equals("properties")) && (str6.equals("http://www.jivesoftware.com/xmlns/xmpp/properties")))
        {
          localMap = parseProperties(paramXmlPullParser);
        }
        else
        {
          localMessage.addExtension(parsePacketExtension((String)localObject, str6, paramXmlPullParser));
        }
      }
      else if ((j == 3) && (paramXmlPullParser.getName().equals("message")))
      {
        i = 1;
      }
    }
    localMessage.setThread(str4);
    if (localMap != null)
    {
      localObject = localMap.keySet().iterator();
      while (((Iterator)localObject).hasNext())
      {
        String str5 = (String)((Iterator)localObject).next();
        localMessage.setProperty(str5, localMap.get(str5));
      }
    }
    return localMessage;
  }

  private static String parseContent(XmlPullParser paramXmlPullParser)
    throws XmlPullParserException, IOException
  {
    int i = paramXmlPullParser.getDepth();
    return parseContentDepth(paramXmlPullParser, i);
  }

  public static String parseContentDepth(XmlPullParser paramXmlPullParser, int paramInt)
    throws XmlPullParserException, IOException
  {
    StringBuffer localStringBuffer = new StringBuffer();
    while ((paramXmlPullParser.next() != 3) || (paramXmlPullParser.getDepth() != paramInt))
      localStringBuffer.append(paramXmlPullParser.getText());
    return localStringBuffer.toString();
  }

  public static Presence parsePresence(XmlPullParser paramXmlPullParser)
    throws Exception
  {
    Presence.Type localType = Presence.Type.available;
    String str1 = paramXmlPullParser.getAttributeValue("", "type");
    if ((str1 != null) && (!str1.equals("")))
      try
      {
        localType = Presence.Type.valueOf(str1);
      }
      catch (IllegalArgumentException localIllegalArgumentException1)
      {
        System.err.println("Found invalid presence type " + str1);
      }
    Presence localPresence = new Presence(localType);
    localPresence.setTo(paramXmlPullParser.getAttributeValue("", "to"));
    localPresence.setFrom(paramXmlPullParser.getAttributeValue("", "from"));
    String str2 = paramXmlPullParser.getAttributeValue("", "id");
    localPresence.setPacketID(str2 == null ? "ID_NOT_AVAILABLE" : str2);
    String str3 = getLanguageAttribute(paramXmlPullParser);
    if ((str3 != null) && (!"".equals(str3.trim())))
      localPresence.setLanguage(str3);
    localPresence.setPacketID(str2 == null ? "ID_NOT_AVAILABLE" : str2);
    int i = 0;
    while (i == 0)
    {
      int j = paramXmlPullParser.next();
      if (j == 2)
      {
        String str4 = paramXmlPullParser.getName();
        String str5 = paramXmlPullParser.getNamespace();
        if (str4.equals("status"))
        {
          localPresence.setStatus(paramXmlPullParser.nextText());
        }
        else if (str4.equals("priority"))
        {
          try
          {
            int k = Integer.parseInt(paramXmlPullParser.nextText());
            localPresence.setPriority(k);
          }
          catch (NumberFormatException localNumberFormatException)
          {
          }
          catch (IllegalArgumentException localIllegalArgumentException2)
          {
            localPresence.setPriority(0);
          }
        }
        else
        {
          Object localObject;
          if (str4.equals("show"))
          {
            localObject = paramXmlPullParser.nextText();
            try
            {
              localPresence.setMode(Presence.Mode.valueOf((String)localObject));
            }
            catch (IllegalArgumentException localIllegalArgumentException3)
            {
              System.err.println("Found invalid presence mode " + (String)localObject);
            }
          }
          else if (str4.equals("error"))
          {
            localPresence.setError(parseError(paramXmlPullParser));
          }
          else if ((str4.equals("properties")) && (str5.equals("http://www.jivesoftware.com/xmlns/xmpp/properties")))
          {
            localObject = parseProperties(paramXmlPullParser);
            Iterator localIterator = ((Map)localObject).keySet().iterator();
            while (localIterator.hasNext())
            {
              String str6 = (String)localIterator.next();
              localPresence.setProperty(str6, ((Map)localObject).get(str6));
            }
          }
          else
          {
            try
            {
              localPresence.addExtension(parsePacketExtension(str4, str5, paramXmlPullParser));
            }
            catch (Exception localException)
            {
              System.err.println("Failed to parse extension packet in Presence packet.");
            }
          }
        }
      }
      else if ((j == 3) && (paramXmlPullParser.getName().equals("presence")))
      {
        i = 1;
      }
    }
    return localPresence;
  }

  public static IQ parseIQ(XmlPullParser paramXmlPullParser, Connection paramConnection)
    throws Exception
  {
    Object localObject1 = null;
    String str1 = paramXmlPullParser.getAttributeValue("", "id");
    String str2 = paramXmlPullParser.getAttributeValue("", "to");
    String str3 = paramXmlPullParser.getAttributeValue("", "from");
    IQ.Type localType = IQ.Type.fromString(paramXmlPullParser.getAttributeValue("", "type"));
    XMPPError localXMPPError = null;
    int i = 0;
    while (i == 0)
    {
      int j = paramXmlPullParser.next();
      if (j == 2)
      {
        String str4 = paramXmlPullParser.getName();
        String str5 = paramXmlPullParser.getNamespace();
        if (str4.equals("error"))
        {
          localXMPPError = parseError(paramXmlPullParser);
        }
        else if ((str4.equals("query")) && (str5.equals("jabber:iq:auth")))
        {
          localObject1 = parseAuthentication(paramXmlPullParser);
        }
        else if ((str4.equals("query")) && (str5.equals("jabber:iq:roster")))
        {
          localObject1 = parseRoster(paramXmlPullParser);
        }
        else if ((str4.equals("query")) && (str5.equals("jabber:iq:register")))
        {
          localObject1 = parseRegistration(paramXmlPullParser);
        }
        else if ((str4.equals("bind")) && (str5.equals("urn:ietf:params:xml:ns:xmpp-bind")))
        {
          localObject1 = parseResourceBinding(paramXmlPullParser);
        }
        else
        {
          Object localObject2 = ProviderManager.getInstance().getIQProvider(str4, str5);
          if (localObject2 != null)
          {
            if ((localObject2 instanceof IQProvider))
              localObject1 = ((IQProvider)localObject2).parseIQ(paramXmlPullParser);
            else if ((localObject2 instanceof Class))
              localObject1 = (IQ)parseWithIntrospection(str4, (Class)localObject2, paramXmlPullParser);
          }
          else if (IQ.Type.RESULT == localType)
            localObject1 = new UnparsedResultIQ(parseContent(paramXmlPullParser));
        }
      }
      else if ((j == 3) && (paramXmlPullParser.getName().equals("iq")))
      {
        i = 1;
      }
    }
    if (localObject1 == null)
    {
      if ((IQ.Type.GET == localType) || (IQ.Type.SET == localType))
      {
        localObject1 = new IQ()
        {
          public String getChildElementXML()
          {
            return null;
          }
        };
        ((IQ)localObject1).setPacketID(str1);
        ((IQ)localObject1).setTo(str3);
        ((IQ)localObject1).setFrom(str2);
        ((IQ)localObject1).setType(IQ.Type.ERROR);
        ((IQ)localObject1).setError(new XMPPError(XMPPError.Condition.feature_not_implemented));
        paramConnection.sendPacket((Packet)localObject1);
        return null;
      }
      localObject1 = new IQ()
      {
        public String getChildElementXML()
        {
          return null;
        }
      };
    }
    ((IQ)localObject1).setPacketID(str1);
    ((IQ)localObject1).setTo(str2);
    ((IQ)localObject1).setFrom(str3);
    ((IQ)localObject1).setType(localType);
    ((IQ)localObject1).setError(localXMPPError);
    return localObject1;
  }

  private static Authentication parseAuthentication(XmlPullParser paramXmlPullParser)
    throws Exception
  {
    Authentication localAuthentication = new Authentication();
    int i = 0;
    while (i == 0)
    {
      int j = paramXmlPullParser.next();
      if (j == 2)
      {
        if (paramXmlPullParser.getName().equals("username"))
          localAuthentication.setUsername(paramXmlPullParser.nextText());
        else if (paramXmlPullParser.getName().equals("password"))
          localAuthentication.setPassword(paramXmlPullParser.nextText());
        else if (paramXmlPullParser.getName().equals("digest"))
          localAuthentication.setDigest(paramXmlPullParser.nextText());
        else if (paramXmlPullParser.getName().equals("resource"))
          localAuthentication.setResource(paramXmlPullParser.nextText());
      }
      else if ((j == 3) && (paramXmlPullParser.getName().equals("query")))
        i = 1;
    }
    return localAuthentication;
  }

  private static RosterPacket parseRoster(XmlPullParser paramXmlPullParser)
    throws Exception
  {
    RosterPacket localRosterPacket = new RosterPacket();
    int i = 0;
    RosterPacket.Item localItem = null;
    while (i == 0)
    {
      if ((paramXmlPullParser.getEventType() == 2) && (paramXmlPullParser.getName().equals("query")))
      {
        String str1 = paramXmlPullParser.getAttributeValue(null, "ver");
        localRosterPacket.setVersion(str1);
      }
      int j = paramXmlPullParser.next();
      if (j == 2)
      {
        String str2;
        if (paramXmlPullParser.getName().equals("item"))
        {
          str2 = paramXmlPullParser.getAttributeValue("", "jid");
          String str3 = paramXmlPullParser.getAttributeValue("", "name");
          localItem = new RosterPacket.Item(str2, str3);
          String str4 = paramXmlPullParser.getAttributeValue("", "ask");
          RosterPacket.ItemStatus localItemStatus = RosterPacket.ItemStatus.fromString(str4);
          localItem.setItemStatus(localItemStatus);
          String str5 = paramXmlPullParser.getAttributeValue("", "subscription");
          RosterPacket.ItemType localItemType = RosterPacket.ItemType.valueOf(str5 != null ? str5 : "none");
          localItem.setItemType(localItemType);
        }
        if ((paramXmlPullParser.getName().equals("group")) && (localItem != null))
        {
          str2 = paramXmlPullParser.nextText();
          if ((str2 != null) && (str2.trim().length() > 0))
            localItem.addGroupName(str2);
        }
      }
      else if (j == 3)
      {
        if (paramXmlPullParser.getName().equals("item"))
          localRosterPacket.addRosterItem(localItem);
        if (paramXmlPullParser.getName().equals("query"))
          i = 1;
      }
    }
    return localRosterPacket;
  }

  private static Registration parseRegistration(XmlPullParser paramXmlPullParser)
    throws Exception
  {
    Registration localRegistration = new Registration();
    HashMap localHashMap = null;
    int i = 0;
    while (i == 0)
    {
      int j = paramXmlPullParser.next();
      if (j == 2)
      {
        if (paramXmlPullParser.getNamespace().equals("jabber:iq:register"))
        {
          String str1 = paramXmlPullParser.getName();
          String str2 = "";
          if (localHashMap == null)
            localHashMap = new HashMap();
          if (paramXmlPullParser.next() == 4)
            str2 = paramXmlPullParser.getText();
          if (!str1.equals("instructions"))
            localHashMap.put(str1, str2);
          else
            localRegistration.setInstructions(str2);
        }
        else
        {
          localRegistration.addExtension(parsePacketExtension(paramXmlPullParser.getName(), paramXmlPullParser.getNamespace(), paramXmlPullParser));
        }
      }
      else if ((j == 3) && (paramXmlPullParser.getName().equals("query")))
        i = 1;
    }
    localRegistration.setAttributes(localHashMap);
    return localRegistration;
  }

  private static Bind parseResourceBinding(XmlPullParser paramXmlPullParser)
    throws IOException, XmlPullParserException
  {
    Bind localBind = new Bind();
    int i = 0;
    while (i == 0)
    {
      int j = paramXmlPullParser.next();
      if (j == 2)
      {
        if (paramXmlPullParser.getName().equals("resource"))
          localBind.setResource(paramXmlPullParser.nextText());
        else if (paramXmlPullParser.getName().equals("jid"))
          localBind.setJid(paramXmlPullParser.nextText());
      }
      else if ((j == 3) && (paramXmlPullParser.getName().equals("bind")))
        i = 1;
    }
    return localBind;
  }

  public static Collection<String> parseMechanisms(XmlPullParser paramXmlPullParser)
    throws Exception
  {
    ArrayList localArrayList = new ArrayList();
    int i = 0;
    while (i == 0)
    {
      int j = paramXmlPullParser.next();
      if (j == 2)
      {
        String str = paramXmlPullParser.getName();
        if (str.equals("mechanism"))
          localArrayList.add(paramXmlPullParser.nextText());
      }
      else if ((j == 3) && (paramXmlPullParser.getName().equals("mechanisms")))
      {
        i = 1;
      }
    }
    return localArrayList;
  }

  public static Collection<String> parseCompressionMethods(XmlPullParser paramXmlPullParser)
    throws IOException, XmlPullParserException
  {
    ArrayList localArrayList = new ArrayList();
    int i = 0;
    while (i == 0)
    {
      int j = paramXmlPullParser.next();
      if (j == 2)
      {
        String str = paramXmlPullParser.getName();
        if (str.equals("method"))
          localArrayList.add(paramXmlPullParser.nextText());
      }
      else if ((j == 3) && (paramXmlPullParser.getName().equals("compression")))
      {
        i = 1;
      }
    }
    return localArrayList;
  }

  public static Map<String, Object> parseProperties(XmlPullParser paramXmlPullParser)
    throws Exception
  {
    HashMap localHashMap = new HashMap();
    int i;
    do
      while (true)
      {
        i = paramXmlPullParser.next();
        if ((i != 2) || (!paramXmlPullParser.getName().equals("property")))
          break;
        int j = 0;
        String str1 = null;
        String str2 = null;
        String str3 = null;
        Object localObject1 = null;
        while (j == 0)
        {
          i = paramXmlPullParser.next();
          Object localObject2;
          if (i == 2)
          {
            localObject2 = paramXmlPullParser.getName();
            if (((String)localObject2).equals("name"))
            {
              str1 = paramXmlPullParser.nextText();
            }
            else if (((String)localObject2).equals("value"))
            {
              str2 = paramXmlPullParser.getAttributeValue("", "type");
              str3 = paramXmlPullParser.nextText();
            }
          }
          else if ((i == 3) && (paramXmlPullParser.getName().equals("property")))
          {
            if ("integer".equals(str2))
              localObject1 = Integer.valueOf(str3);
            else if ("long".equals(str2))
              localObject1 = Long.valueOf(str3);
            else if ("float".equals(str2))
              localObject1 = Float.valueOf(str3);
            else if ("double".equals(str2))
              localObject1 = Double.valueOf(str3);
            else if ("boolean".equals(str2))
              localObject1 = Boolean.valueOf(str3);
            else if ("string".equals(str2))
              localObject1 = str3;
            else if ("java-object".equals(str2))
              try
              {
                localObject2 = StringUtils.decodeBase64(str3);
                ObjectInputStream localObjectInputStream = new ObjectInputStream(new ByteArrayInputStream((byte[])localObject2));
                localObject1 = localObjectInputStream.readObject();
              }
              catch (Exception localException)
              {
                localException.printStackTrace();
              }
            if ((str1 != null) && (localObject1 != null))
              localHashMap.put(str1, localObject1);
            j = 1;
          }
        }
      }
    while ((i != 3) || (!paramXmlPullParser.getName().equals("properties")));
    return localHashMap;
  }

  public static SASLMechanism.Failure parseSASLFailure(XmlPullParser paramXmlPullParser)
    throws Exception
  {
    String str = null;
    int i = 0;
    while (i == 0)
    {
      int j = paramXmlPullParser.next();
      if (j == 2)
      {
        if (!paramXmlPullParser.getName().equals("failure"))
          str = paramXmlPullParser.getName();
      }
      else if ((j == 3) && (paramXmlPullParser.getName().equals("failure")))
        i = 1;
    }
    return new SASLMechanism.Failure(str);
  }

  public static StreamError parseStreamError(XmlPullParser paramXmlPullParser)
    throws IOException, XmlPullParserException
  {
    int i = paramXmlPullParser.getDepth();
    int j = 0;
    Object localObject = null;
    String str1 = null;
    while (j == 0)
    {
      int k = paramXmlPullParser.next();
      if (k == 2)
      {
        String str2 = paramXmlPullParser.getNamespace();
        if ("urn:ietf:params:xml:ns:xmpp-streams".equals(str2))
        {
          String str3 = paramXmlPullParser.getName();
          if ((str3.equals("text")) && (!paramXmlPullParser.isEmptyElementTag()))
          {
            paramXmlPullParser.next();
            str1 = paramXmlPullParser.getText();
          }
          else
          {
            localObject = str3;
          }
        }
      }
      else if ((k == 3) && (i == paramXmlPullParser.getDepth()))
      {
        j = 1;
      }
    }
    return new StreamError(localObject, str1);
  }

  public static XMPPError parseError(XmlPullParser paramXmlPullParser)
    throws Exception
  {
    String str1 = "urn:ietf:params:xml:ns:xmpp-stanzas";
    String str2 = "-1";
    String str3 = null;
    String str4 = null;
    Object localObject = null;
    ArrayList localArrayList = new ArrayList();
    for (int i = 0; i < paramXmlPullParser.getAttributeCount(); i++)
    {
      if (paramXmlPullParser.getAttributeName(i).equals("code"))
        str2 = paramXmlPullParser.getAttributeValue("", "code");
      if (paramXmlPullParser.getAttributeName(i).equals("type"))
        str3 = paramXmlPullParser.getAttributeValue("", "type");
    }
    i = 0;
    while (i == 0)
    {
      int j = paramXmlPullParser.next();
      if (j == 2)
      {
        if (paramXmlPullParser.getName().equals("text"))
        {
          str4 = paramXmlPullParser.nextText();
        }
        else
        {
          String str5 = paramXmlPullParser.getName();
          String str6 = paramXmlPullParser.getNamespace();
          if ("urn:ietf:params:xml:ns:xmpp-stanzas".equals(str6))
            localObject = str5;
          else
            localArrayList.add(parsePacketExtension(str5, str6, paramXmlPullParser));
        }
      }
      else if ((j == 3) && (paramXmlPullParser.getName().equals("error")))
        i = 1;
    }
    XMPPError.Type localType = XMPPError.Type.CANCEL;
    try
    {
      if (str3 != null)
        localType = XMPPError.Type.valueOf(str3.toUpperCase());
    }
    catch (IllegalArgumentException localIllegalArgumentException)
    {
      localIllegalArgumentException.printStackTrace();
    }
    return new XMPPError(Integer.parseInt(str2), localType, localObject, str4, localArrayList);
  }

  public static PacketExtension parsePacketExtension(String paramString1, String paramString2, XmlPullParser paramXmlPullParser)
    throws Exception
  {
    Object localObject = ProviderManager.getInstance().getExtensionProvider(paramString1, paramString2);
    if (localObject != null)
    {
      if ((localObject instanceof PacketExtensionProvider))
        return ((PacketExtensionProvider)localObject).parseExtension(paramXmlPullParser);
      if ((localObject instanceof Class))
        return (PacketExtension)parseWithIntrospection(paramString1, (Class)localObject, paramXmlPullParser);
    }
    DefaultPacketExtension localDefaultPacketExtension = new DefaultPacketExtension(paramString1, paramString2);
    int i = 0;
    while (i == 0)
    {
      int j = paramXmlPullParser.next();
      if (j == 2)
      {
        String str1 = paramXmlPullParser.getName();
        if (paramXmlPullParser.isEmptyElementTag())
        {
          localDefaultPacketExtension.setValue(str1, "");
        }
        else
        {
          j = paramXmlPullParser.next();
          if (j == 4)
          {
            String str2 = paramXmlPullParser.getText();
            localDefaultPacketExtension.setValue(str1, str2);
          }
        }
      }
      else if ((j == 3) && (paramXmlPullParser.getName().equals(paramString1)))
      {
        i = 1;
      }
    }
    return localDefaultPacketExtension;
  }

  private static String getLanguageAttribute(XmlPullParser paramXmlPullParser)
  {
    for (int i = 0; i < paramXmlPullParser.getAttributeCount(); i++)
    {
      String str = paramXmlPullParser.getAttributeName(i);
      if (("xml:lang".equals(str)) || (("lang".equals(str)) && ("xml".equals(paramXmlPullParser.getAttributePrefix(i)))))
        return paramXmlPullParser.getAttributeValue(i);
    }
    return null;
  }

  public static Object parseWithIntrospection(String paramString, Class<?> paramClass, XmlPullParser paramXmlPullParser)
    throws Exception
  {
    int i = 0;
    Object localObject1 = paramClass.newInstance();
    while (i == 0)
    {
      int j = paramXmlPullParser.next();
      if (j == 2)
      {
        String str1 = paramXmlPullParser.getName();
        String str2 = paramXmlPullParser.nextText();
        Class localClass = localObject1.getClass().getMethod("get" + Character.toUpperCase(str1.charAt(0)) + str1.substring(1), new Class[0]).getReturnType();
        Object localObject2 = decode(localClass, str2);
        localObject1.getClass().getMethod("set" + Character.toUpperCase(str1.charAt(0)) + str1.substring(1), new Class[] { localClass }).invoke(localObject1, new Object[] { localObject2 });
      }
      else if ((j == 3) && (paramXmlPullParser.getName().equals(paramString)))
      {
        i = 1;
      }
    }
    return localObject1;
  }

  private static Object decode(Class<?> paramClass, String paramString)
    throws Exception
  {
    if (paramClass.getName().equals("java.lang.String"))
      return paramString;
    if (paramClass.getName().equals("boolean"))
      return Boolean.valueOf(paramString);
    if (paramClass.getName().equals("int"))
      return Integer.valueOf(paramString);
    if (paramClass.getName().equals("long"))
      return Long.valueOf(paramString);
    if (paramClass.getName().equals("float"))
      return Float.valueOf(paramString);
    if (paramClass.getName().equals("double"))
      return Double.valueOf(paramString);
    if (paramClass.getName().equals("java.lang.Class"))
      return Class.forName(paramString);
    return null;
  }

  public static class UnparsedResultIQ extends IQ
  {
    private final String str;

    public UnparsedResultIQ(String paramString)
    {
      this.str = paramString;
    }

    public String getChildElementXML()
    {
      return this.str;
    }
  }
}

/* Location:           D:\hygieia\userclient\common\libs\easemobchat_2.1.8.jar
 * Qualified Name:     org.jivesoftware.smack.util.PacketParserUtils
 * JD-Core Version:    0.6.1
 */